2019鐵人賽
salary table
name | salary |
---|---|
Jack | 1500 |
John | 250 |
Jason | 300 |
Jim | 700 |
AVG 用來計算平均值。
SELECT AVG(salary)
FROM salarys;
結果
AVG(salary)
687.5
COUNT 計算出在表格中有多少筆資料。
SELECT COUNT(name)
FROM salarys;
結果
COUNT(name)
4
MAX 用來計算一個欄位的最大值。
SELECT MAX(salary)
FROM salarys;
結果
MAX(salary)
1500
MIN 用來計算一個欄位的最小值。
SELECT MIN(salary)
FROM salarys;
結果
MIN(salary)
250
SUM 用來計算一個欄位的總合。
SELECT SUM(salary)
FROM salarys;
結果
SUM(salary)
2750
reference from https://www.1keydata.com/sql/sql-average.html
reference from https://www.1keydata.com/sql/sqlcount.html
reference from https://www.1keydata.com/sql/sql-max.html
reference from https://www.1keydata.com/sql/sql-min.html
reference from https://www.1keydata.com/sql/sql-sum.html
reference from IBSN 978-986-476-232-3